﻿
IF  EXISTS (SELECT * FROM sys.objects WHERE object_id = OBJECT_ID(N'[dbo].[sproc_AddTeam]') AND type in (N'P', N'PC'))
    DROP PROCEDURE [dbo].[sproc_AddTeam];
GO
CREATE PROCEDURE [dbo].[sproc_AddTeam]
    @ClassName nvarchar(300),
    @ClassRemark nvarchar(300),
    @ClassType int,
    @ClassParentID int,
    @AddedBy nvarchar(300),
    @AddedDate datetime,
    @Status int
/*

=========================================================

功能:新增一个组节点
参数:
    @ClassName         节点名称
    @ClassRemark        节点介绍
    @ClassType         节点类型
    @ClassParentID     节点的父ID
    @AddedBy         节点建立者
    @AddedDate        节点的建立时间
    @Status        节点的状态

注释:相关的sproc_AddProject,添加项目,本过程能添加任何节点类型
=========================================================

*/
AS

SET NOCOUNT ON

DECLARE @ClassID int
CREATE TABLE #T (ClassID int)

INSERT INTO #T EXEC sproc_AddClass @ClassName,@ClassRemark,@ClassType,@ClassParentID,@AddedBy,@AddedDate,@Status
    SELECT @ClassID = ClassID FROM #T

IF @ClassID>0
    INSERT INTO UDS_Assign_Rule (act_id,based_on,team_id) 
        SELECT act_id,2,@ClassID FROM uds_DefaultRight WHERE objecttype = 2


SET NOCOUNT OFF